package cn.gok.HomeWork;

import java.util.Random;

class Worker{
    private String name;
    private String job;
    private int salary;

    public int doJob(int months){
        System.out.println(this.name+"工作了"+months+"个月，获得"+this.salary*months+"工资");
        return months*salary;
    }

    public Worker(String name, String job, int salary) {
        this.name = name;
        this.job = job;
        this.salary = salary;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getJob() {
        return job;
    }

    public void setJob(String job) {
        this.job = job;
    }

    public int getSalary() {
        return salary;
    }

    public void setSalary(int salary) {
        this.salary = salary;
    }

    @java.lang.Override
    public java.lang.String toString() {
        return "Worker{" +
                "name='" + name + '\'' +
                ", job='" + job + '\'' +
                ", salary=" + salary +
                '}';
    }
}
class SuperWoker extends Worker{


    Random r= new Random();
    float f1 = r.nextFloat();
    public   float bonus=(1+f1);


    public int doJob(int months,int addtionalHours) {
        int b=(int)(months*super.getSalary()*bonus+bonus*getSalary()*addtionalHours/100);
        System.out.println(super.getName()+"工作了"+months+"个月"+"且加班了"+addtionalHours+"个小时"+"获得了"+b+"工资");
        return b;
    }

    @Override
    public int doJob(int months) {
        int a=(int)((months*getSalary())*bonus);
        System.out.println(super.getName()+"工作了"+months+"个月，获得了"+a+"工资");
        return  a;
    }


    public SuperWoker(String name, String job, int salary) {
        super(name, job, salary);
    }

}

public class Homeworkday2 {
    public static void main(String[] args) {
        Worker worker=new Worker("小林","java",3000);
        worker.doJob(3);
        SuperWoker superWoker=new SuperWoker("小林","java",3000);
        superWoker.doJob(3);
        superWoker.doJob(3, 8);
    }

}
